summaryrefslogtreecommitdiff
path: root/app/[lng]/test/table-v2/column-defs.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/[lng]/test/table-v2/column-defs.ts')
-rw-r--r--app/[lng]/test/table-v2/column-defs.ts60
1 files changed, 60 insertions, 0 deletions
diff --git a/app/[lng]/test/table-v2/column-defs.ts b/app/[lng]/test/table-v2/column-defs.ts
new file mode 100644
index 00000000..3ece4287
--- /dev/null
+++ b/app/[lng]/test/table-v2/column-defs.ts
@@ -0,0 +1,60 @@
+/**
+ * Column Definitions for Server Actions
+ *
+ * 서버 액션에서 DrizzleTableAdapter가 사용할 컬럼 정의입니다.
+ * React 컴포넌트 없이 accessorKey만 정의합니다.
+ */
+
+import { ColumnDef } from "@tanstack/react-table";
+import { TestProduct } from "@/db/schema/test-table-v2";
+
+/**
+ * 서버 사이드 기능을 위한 컬럼 메타 정보
+ */
+export interface ServerColumnMeta {
+ /** 서버에서 GROUP BY 가능 여부 (DB 컬럼에 직접 매핑되어야 함) */
+ serverGroupable?: boolean;
+ /** 서버에서 정렬 가능 여부 */
+ serverSortable?: boolean;
+ /** 서버에서 필터 가능 여부 */
+ serverFilterable?: boolean;
+}
+
+// === Product Columns (Server-side compatible) ===
+// DrizzleTableAdapter는 accessorKey만 사용하므로 cell renderer가 필요 없습니다.
+// meta.serverGroupable로 서버 GROUP BY 지원 여부를 표시합니다.
+
+type ProductColumnDef = ColumnDef<TestProduct, any> & { meta?: ServerColumnMeta };
+
+export const productColumnDefs: ProductColumnDef[] = [
+ { accessorKey: "id", meta: { serverGroupable: false } }, // PK는 그룹핑 의미 없음
+ { accessorKey: "sku", meta: { serverGroupable: false } }, // Unique 값
+ { accessorKey: "name", meta: { serverGroupable: false } }, // 이름은 그룹핑 비효율
+ { accessorKey: "category", meta: { serverGroupable: true } }, // ✅ 그룹핑 적합
+ { accessorKey: "price", meta: { serverGroupable: false } },
+ { accessorKey: "stock", meta: { serverGroupable: false } },
+ { accessorKey: "status", meta: { serverGroupable: true } }, // ✅ 그룹핑 적합
+ { accessorKey: "isNew", meta: { serverGroupable: true } }, // ✅ 그룹핑 적합
+ { accessorKey: "createdAt", meta: { serverGroupable: false } },
+ { accessorKey: "updatedAt", meta: { serverGroupable: false } },
+];
+
+// === Order Columns for joined data (Pattern 3) ===
+// Custom Service에서는 DrizzleTableAdapter를 사용하지 않고 직접 쿼리합니다.
+// 조인된 데이터의 컬럼은 단일 테이블에 매핑되지 않기 때문입니다.
+
+export type OrderWithDetails = {
+ id: number;
+ orderNumber: string;
+ quantity: number;
+ unitPrice: string;
+ totalAmount: string;
+ status: string;
+ orderedAt: Date;
+ customerName: string | null;
+ customerEmail: string | null;
+ customerTier: string | null;
+ productName: string | null;
+ productSku: string | null;
+};
+